/*
 ***************************************************************************
 * MediaTeK Inc.
 * 4F, No. 2 Technology	5th	Rd.
 * Science-based Industrial	Park
 * Hsin-chu, Taiwan, R.O.C.
 *
 * (c) Copyright 2002-2012, MTK.
 *
 * All rights reserved.	MediaTeK's source	code is	an unpublished work	and	the
 * use of a	copyright notice does not imply	otherwise. This	source code
 * contains	confidential trade secret material of MediaTeK Tech. Any attemp
 * or participation	in deciphering,	decoding, reverse engineering or in	any
 * way altering	the	source code	is stricitly prohibited, unless	the	prior
 * written consent of MediaTeK, Inc. is obtained.
 ***************************************************************************

	Module Name:
	omci_me_alcatel_nodetable.c

	Abstract:

	Revision History:
	Who			When			What
	--------	----------		----------------------------------------------
	Name		Date			Modification logs
	mingang.tan	2018/8/16	Create
*/
#include "omci_me.h"
#include "omci_general_func.h"


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   VoIP Call statistics
********************************************************************************************************************************/
int omciMEInitForVoIPCallStatistics(omciManageEntity_t *omciManageEntity_p)
{
    omciManageEntity_t *tmpOmciManageEntity_p = NULL;
    
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

    if(omciManageEntity_p == NULL)
        return -1;
    
    tmpOmciManageEntity_p = omciManageEntity_p;
    /* init some param for this ME */
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT]   = omciCreateAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET]     = omciGetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET]     = omciSetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET_NEXT]= omciGetNextAction;
    
    return 0;
}

static AttributeFunc _voipCallHistoryTableGetFunc = {
	getGeneralTableValue,
	NULL,
};


omciAttriDescript_t omciAttriDescriptListVoIPCallStatistics[]={
{0, "meId",                 2,		ATTR_ACCESS_R,  ATTR_FORMAT_UNSIGNED_INT,   0,  0x0000FFFF, 0,  NULL,  NO_AVC,	&generalGetFunc},
{1, "Call History Table",   120,	ATTR_ACCESS_R,  ATTR_FORMAT_TABLE,          0,  0,          0,  NULL,  NO_AVC,	&_voipCallHistoryTableGetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL} 
};



/****************************************************************************************************************************
ALCATEL Vendor Specific ME:   Clock Data Set
******************************************************************************************************************************/
int omciMEInitForClockDataSet(omciManageEntity_t *omciManageEntity_p){
    omciManageEntity_t *tmpOmciManageEntity_p = NULL;
    
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

    if(omciManageEntity_p == NULL)
        return -1;
    
    tmpOmciManageEntity_p = omciManageEntity_p;
    /* init some param for this ME */
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT]   = omciCreateAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET]     = omciGetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET]     = omciSetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE]  = omciDeleteAction;    
    return 0;
}

uint8_t alarmIdTableClockDataSet[] = {
    OMCI_ALARM_ID_CLOCK_DATA_SET_OUN_LOST_ToD_SYNC_ALARM,
    0
};

omciAttriDescript_t omciAttriDescriptListClockDataSet[]={
{0, "meId",             2,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,       0x01,   0xFFFE, 0,  NULL,   NO_AVC, &generalGetFunc},   
{1, "Domain",           1,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,               0,      0xFF,   0,  NULL,   NO_AVC, &generalGetSetFunc},
{2, "Clock class",      1,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,       0,      0xFF,   0,  NULL,   NO_AVC, &generalGetSetFunc},
{3, "Clock accuracy",   1,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,               0,      0xFF,   0,  NULL,   NO_AVC, &generalGetSetFunc},
{4, "Clock priority1",  1,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,       0,      0xFF,   0,  NULL,   NO_AVC, &generalGetSetFunc},
{5, "Clock priority2",  1,  ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,       0,      0xFF,   0,  NULL,   NO_AVC, &generalGetSetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Master Configure Data Profile
********************************************************************************************************************************/

int omciMEInitForPTPMasterConfigDataProfile(omciManageEntity_t *omciManageEntity_p){
    omciManageEntity_t *tmpOmciManageEntity_p = NULL;
    
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

    if(omciManageEntity_p == NULL)
        return -1;
    
    tmpOmciManageEntity_p = omciManageEntity_p;
    /* init some param for this ME */
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT]   = omciCreateAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET]     = omciGetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET]     = omciSetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE]  = omciDeleteAction;    
    return 0;
}

omciAttriDescript_t omciAttriDescriptListPTPMasterConfigDataProfile[]={
{0, "meId",                     	2,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,  0x01,   0xFFFE, 0,  NULL,    NO_AVC, &generalGetFunc},
{1, "Clock Data Set Pointer",   	2,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_POINTER,       0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{2, "Step mode",                	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,  0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{3, "Delay mechanism",          	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_UNSIGNED_INT,  0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{4, "Interval of sync message", 	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,    0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{5, "Interval of delay message",	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,    0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{6, "Interval of pdelay message",	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT,   	0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{7, "Interval of announce message",	1,ATTR_ACCESS_R_W_SET_CREATE,ATTR_FORMAT_SIGNED_INT, 	0,      0xFF,   0,  NULL,    NO_AVC, &generalGetSetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   PTP Port
********************************************************************************************************************************/

int omciMEInitForPTPPort(omciManageEntity_t *omciManageEntity_p){
    omciManageEntity_t *tmpOmciManageEntity_p = NULL;
    
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "\nenter omciMEInitForPTPPort\n");

    if(omciManageEntity_p == NULL)
        return -1;
    
    tmpOmciManageEntity_p = omciManageEntity_p;
    /* init some param for this ME */
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT]   = omciCreateAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET]     = omciGetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET]     = omciSetAction;
    tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE]  = omciDeleteAction;    
    return 0;
}

omciAttriDescript_t omciAttriDescriptListPTPPort[]={
{0, "meId",                                2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,  0x01,   0xFFFE, 0,  NULL,  NO_AVC, &generalGetFunc},
{1, "PTP Master Configure Data pointer",   2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_POINTER,       0,      0xFFFF, 0,  NULL,  NO_AVC, &generalGetSetFunc},
{2, "PPTP UNI pointer",                    2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_POINTER,       0,      0xFFFF, 0,  NULL,  NO_AVC, &generalGetSetFunc},
{3, "Admin state",                         1, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_ENUM,          0,      1,      0,  NULL,  NO_AVC, &generalGetSetFunc},
{4, "TCI",                                 2, ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,  0,      0xFFFF, 0,  NULL,  NO_AVC, &generalGetSetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   UNI Supplemental 1 V2
********************************************************************************************************************************/

int omciMeInitForUNISupplemental1V2(omciManageEntity_t *omciManageEntity_p)
{
	omciManageEntity_t *tmpOmciManageEntity_p = NULL;
	
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

	if(omciManageEntity_p == NULL)
		return -1;
	
	tmpOmciManageEntity_p = omciManageEntity_p;
	/* init some param for this ME */
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	
	return 0;
}


omciAttriDescript_t omciAttriDescriptListUNISupplemental1V2[]={
{0, "meId",                             2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetFunc},
{1, "Downstream Tag Handling Mode",     1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{2, "IGMP Access Control Method",       1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{3, "Multicast VID Value",              2,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{4, "Multicast P-Bit Value",            1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{5, "IGMPChannelBridgePortNumber",      1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{6, "Upstream Default Priority",        1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{7, "Maximum Number of Hosts per UNI",  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL,    NO_AVC, &generalGetSetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0,  NULL}
};


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Total GEM Port PM

********************************************************************************************************************************/

int omciMeInitForTotalGemPortPM(omciManageEntity_t *omciManageEntity_p){
	omciManageEntity_ptr tmpOmciManageEntity_p = omciManageEntity_p;
	
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT] = omciCreateAction;//create by OLT
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE] = omciDeleteAction;//delete by OLT
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET_CURR_DATA] = omciGetCurrentDataAction;
	/* if need ONU auto create a ME instance, create here */

	return 0;
}

omciAttriDescript_t omciAttriDescriptListTotalGemPortPm[] = {
    {0, "meId" ,                                2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,   0,  0x0000FFFF, 0,  NULL, NO_AVC,   &generalGetSetFunc},
    {1, "Interval end time" ,                   1 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {2, "Threshold data 1/2 id",                2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetSetFunc},
    {3, "Lost GEM Fragment Counter Downstream", 4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, YES_TCA,  &generalGetFunc},
    {4, "Lost GEM Fragment Counter Upstream",   4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, YES_TCA,  &generalGetFunc},
    {5, "Received GEM Fragment Counter",        5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {6, "Received GEM Blocks",                  5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {7, "Transmitted GEM Blocks" ,              5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {8, "Impaired blocks" ,                     4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, YES_TCA,  &generalGetFunc},
    {9, "Transmitted GEM Fragment Counter" ,    5 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {10, "Bad GEM Headers Received Counter" ,   4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, YES_TCA,  &generalGetFunc},
    {11, "Received GEM Blocks 64Bit" ,          8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {12, "Transmitted GEM Blocks 64Bit" ,       8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,          NULL, NO_AVC,   &generalGetFunc},
    {255, "" , 0 , 0,  0, 0,0, 0, NULL , 0, NULL}
};


/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Ethernet Traffic PM

********************************************************************************************************************************/

int omciMeInitForEthernetTrafficPM(omciManageEntity_t *omciManageEntity_p){
	omciManageEntity_ptr tmpOmciManageEntity_p = omciManageEntity_p;
	
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT] = omciCreateAction;//create by OLT
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE] = omciDeleteAction;//delete by OLT
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET_CURR_DATA] = omciGetCurrentDataAction;
	/* if need ONU auto create a ME instance, create here */

	return 0;
}


omciAttriDescript_t omciAttriDescriptListEthernetTrafficPm[] = {
{0, "meId" ,                                    2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,   0,  0x0000FFFF, 0,          NULL,    NO_AVC,     &generalGetSetFunc},
{1, "Interval end time" ,                       1 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{2, "Threshold data 1/2 id",                    2 , ATTR_ACCESS_R_W_SET_CREATE, ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetSetFunc},
{3, "Upstream Frames Counter",                  4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{4, "Downstream Frames Counter",                4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{5, "Upstream Bytes Counter",                   4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{6, "Downstream Bytes Counter",                 4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{7, "Dropped Upstream Frames Counter" ,         4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    YES_TCA,    &generalGetFunc},
{8, "Dropped Upstream Bytes Counter" ,          4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    YES_TCA,    &generalGetFunc},
{9, "Dropped Downstream Frames Counter" ,       4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    YES_TCA,    &generalGetFunc},
{10, "Multicast Upstream Frames Counter" ,      4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{11, "Multicast Downstream Frames Counter" ,    4 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{12, "Upstream Bytes Counter 64Bit" ,           8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{13, "Downstream Bytes Counter 64Bit" ,         8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{14, "Upstream Frames Counter 64Bit" ,          8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{15, "Downstream Frames Counter 64Bit" ,        8 , ATTR_ACCESS_R,              ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,          NULL,    NO_AVC,     &generalGetFunc},
{255, "" , 0 , 0,  0, 0,0, 0, NULL , 0 ,NULL}
};



/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Downstream Egress Behavior Supplemental 1

********************************************************************************************************************************/

int omciMeInitForVlanTagDownstreamSupplemental1(omciManageEntity_t *omciManageEntity_p){
	omciManageEntity_ptr tmpOmciManageEntity_p = omciManageEntity_p;
	
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	/* if need ONU auto create a ME instance, create here */

	return 0;
}

static int _setVlanTxBehaviorTableValue(uint8_t *value, uint8_t *meInstantPtr, omciAttriDescript_ptr omciAttribute, uint8_t flag)
{
    omciTableAttriValue_t *tableConent_ptr = NULL; 
    uint8_t *tableValue_ptr = NULL;
    uint8_t *tmp_ptr = NULL;
    omciMeInst_t *tmpomciMeInst_ptr = NULL;
    uint8_t entryNum = 0;
    uint8_t specialByte = 0;  /*0:del entry, 1: add entry*/
    uint8_t actionFlag = ATTRIBUTE_TABLE_NULL;
    int ret = 0;
    uint16_t length = 0;
    uint16_t entryLength = 0;
    uint16_t sameEntryNum = 0;

    if((value == NULL) || (meInstantPtr == NULL) || (omciAttribute == NULL))
        return -1;
    tmpomciMeInst_ptr = (omciMeInst_t *)meInstantPtr;
    entryNum = *value;
    specialByte = *(value+1);
    entryLength = omciAttribute->attriLen;
    
    tableConent_ptr = omciGetTableValueByIndex(tmpomciMeInst_ptr, omciAttribute->attriIndex);
    if(tableConent_ptr != NULL){
        tableValue_ptr = tableConent_ptr->tableValue_p;
    }
    tmp_ptr = tableValue_ptr;
    
    /*search current entry*/
    while(tmp_ptr != NULL){
        if(entryNum == *tmp_ptr){
            if(specialByte & 0x80)
                actionFlag = ATTRIBUTE_TABLE_REPLACE_ENTRY;
            else
                actionFlag = ATTRIBUTE_TABLE_DEL_ENTRY;
            break;
        }
        length += entryLength;
        if(length >= tableConent_ptr->tableSize){
            if(specialByte & 0x80)
            {
                actionFlag = ATTRIBUTE_TABLE_ADD_ENTRY;
                break;
            }
            else
            {
                omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s] [%d] error parameter\n",__FUNCTION__, __LINE__);
                return -1;
            }
        }
        tmp_ptr += entryLength;
        sameEntryNum++;
    }
    
    ret = omciAddTableValueToInst(tmpomciMeInst_ptr, tableConent_ptr, omciAttribute, value, sameEntryNum, actionFlag);
    
    return ret;
}


static AttributeFunc _VlanTxBehaviorTableFunc = {
	getGeneralTableValue,
	_setVlanTxBehaviorTableValue,
};


omciAttriDescript_t omciAttriDescriptListVlanTagDownstreamSupplemental1[] = {
{0, "meId" ,                    2 , ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0x0000FFFF, 0,  NULL, NO_AVC, &generalGetFunc},
{1, "Vlan Tx Default Tag" ,     1 , ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,          0,  NULL, NO_AVC, &generalGetSetFunc},
{2, "Vlan Tx Behavior Table" ,  6 , ATTR_ACCESS_R_W,    ATTR_FORMAT_TABLE,          0,  0,          0,  NULL, NO_AVC, &_VlanTxBehaviorTableFunc},
{255, "" , 0 , 0,  0, 0,0, 0, NULL , 0, NULL}
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   Vlan Tag Upstream Policer

********************************************************************************************************************************/

int omciMeInitForVlanTagUpstreamPolicer(omciManageEntity_t *omciManageEntity_p){
	omciManageEntity_ptr tmpOmciManageEntity_p = omciManageEntity_p;
	
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	/* if need ONU auto create a ME instance, create here */

	return 0;
}

static int _setVlanRxPolicerTableValue(uint8_t *value, uint8_t *meInstantPtr, omciAttriDescript_ptr omciAttribute, uint8_t flag)
{
    omciTableAttriValue_t *tableConent_ptr = NULL; 
    uint8_t *tableValue_ptr = NULL;
    uint8_t *tmp_ptr = NULL;
    omciMeInst_t *tmpomciMeInst_ptr = NULL;
    uint8_t entryNum = 0;
    uint16_t vlanId = 0;  /*bit1, 0:del entry, 1: add entry*/
    uint8_t actionFlag = ATTRIBUTE_TABLE_NULL;
    int ret = 0;
    uint16_t length = 0;
    uint16_t entryLength = 0;
    uint16_t sameEntryNum = 0;

    if((value == NULL) || (meInstantPtr == NULL) || (omciAttribute == NULL))
        return -1;
    tmpomciMeInst_ptr = (omciMeInst_t *)meInstantPtr;
    entryNum = *value;
    vlanId = get16(value+1);
    entryLength = omciAttribute->attriLen;
    
    tableConent_ptr = omciGetTableValueByIndex(tmpomciMeInst_ptr, omciAttribute->attriIndex);
    if(tableConent_ptr != NULL){
        tableValue_ptr = tableConent_ptr->tableValue_p;
    }
    tmp_ptr = tableValue_ptr;
    
    /*search current entry*/
    while(tmp_ptr != NULL){
        if(entryNum == *tmp_ptr){
            if(vlanId & 0x0001)
                actionFlag = ATTRIBUTE_TABLE_REPLACE_ENTRY;
            else
                actionFlag = ATTRIBUTE_TABLE_DEL_ENTRY;
            break;
        }
        length += entryLength;
        if(length >= tableConent_ptr->tableSize){
            if(vlanId & 0x0001)
            {
                actionFlag = ATTRIBUTE_TABLE_ADD_ENTRY;
                break;
            }
            else
            {
                omcidbgPrintf(OMCI_DEBUG_LEVEL_ERROR,"[%s] [%d] error parameter\n",__FUNCTION__, __LINE__);
                return -1;
            }
        }
        tmp_ptr += entryLength;
        sameEntryNum++;
    }
    
    ret = omciAddTableValueToInst(tmpomciMeInst_ptr, tableConent_ptr, omciAttribute, value, sameEntryNum, actionFlag);
    
    return ret;
}


static AttributeFunc _VlanRxPolicerTableFunc = {
	NULL,
	_setVlanRxPolicerTableValue,
};


omciAttriDescript_t omciAttriDescriptListVlanTagUpstreamPolicer[] = {
{0, "meId" ,                    2 , ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT, 0, 0xFFFF,    0,      NULL,     NO_AVC, &generalGetFunc},
{1, "Vlan Rx Policer Table" ,   19, ATTR_ACCESS_W,      ATTR_FORMAT_TABLE,        0, 0,         0,      NULL,     NO_AVC, &_VlanRxPolicerTableFunc},
{255, "" , 0 , 0,  0, 0,0, 0, NULL , 0, NULL}
};

/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   GEMPort Protocol Monitoring History Data - Part 2

********************************************************************************************************************************/

int omciMeInitForGEMPortProtocolMonitoringHistoryDataPart2(omciManageEntity_t *omciManageEntity_p)
{
	omciManageEntity_t *tmpOmciManageEntity_p = NULL;
	
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

	if(omciManageEntity_p == NULL)
		return -1;
	
	tmpOmciManageEntity_p = omciManageEntity_p;
	/* init some param for this ME */
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_CREAT] = omciCreateAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_DELETE] = omciDeleteAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET_CURR_DATA] = omciGetCurrentDataAction;
	
	return 0;
}

omciAttriDescript_t omciAttriDescriptListGEMPortProtocolMonitoringHistoryDataPart2[]={
{0, "meId",                                 2,  ATTR_ACCESS_R_SET_CREATE,       ATTR_FORMAT_UNSIGNED_INT,   0x01,   0xFF,   0,  NULL, NO_AVC,   &generalGetSetFunc},
{1, "interval end time",                    1,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,   0,      0,      0,  NULL, NO_AVC,   &generalGetFunc},
{2, "threshold data 1/2 id",                2,  ATTR_ACCESS_R_W_SET_CREATE,     ATTR_FORMAT_UNSIGNED_INT,   0,      0,      0,  NULL, NO_AVC,   &generalGetSetFunc},
{3, "Lost GEM Fragment Counter(Upstream)",  4,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,   0,      0,      0,  NULL, YES_TCA,  &generalGetFunc},
{4, "Transmitted GEM Fragment Counter",     5,  ATTR_ACCESS_R,                  ATTR_FORMAT_UNSIGNED_INT,   0,      0,      0,  NULL, NO_AVC,   &generalGetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Optical Supervision Status

********************************************************************************************************************************/

int omciMeInitForONTOpticalSupervisionStatus(omciManageEntity_t *omciManageEntity_p)
{
	omciManageEntity_t *tmpOmciManageEntity_p = NULL;
	
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

	if(omciManageEntity_p == NULL)
		return -1;
	
	tmpOmciManageEntity_p = omciManageEntity_p;
	/* init some param for this ME */
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	
	return 0;
}

omciAttriDescript_t omciAttriDescriptListONTOpticalSupervisionStatus[]={
{0, "meId",                                         2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{1, "Power feed voltage measurement indicator",     1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{2, "Power Feed Voltage",                           2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{3, "Receive optical power measurement indicator",  1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{4, "Receive Optical Power",                        2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{5, "Transmit optical power measurement indicator", 1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{6, "Transmit Optical Power",                       2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{7, "Laser Bias Current measurement indicator",     1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{8, "Laser Bias Current",                           2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{9, "Temperature measurement indicator",            1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{10, "Temperature",                                 2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};
/*******************************************************************************************************************************
ALCATEL Vendor Specific ME:   ONT Generic V2

********************************************************************************************************************************/

int omciMeInitForONTGenericV2(omciManageEntity_t *omciManageEntity_p)
{
	omciManageEntity_t *tmpOmciManageEntity_p = NULL;
	
    omcidbgPrintf(OMCI_DEBUG_LEVEL_TRACE, "[%s][%d] enter\n", __FUNCTION__, __LINE__);

	if(omciManageEntity_p == NULL)
		return -1;
	
	tmpOmciManageEntity_p = omciManageEntity_p;
	/* init some param for this ME */
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_GET] = omciGetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_SET] = omciSetAction;
	tmpOmciManageEntity_p->omciActionFunc[MT_OMCI_MSG_TYPE_AVC] = omciHandshakeAVCResponseAction;
	
	return 0;
}

omciAttriDescript_t omciAttriDescriptListONTGenericV2[]={
{0, "meId",                                     2,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{1, "IGMPSnoopEnable",                          1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{2, "ForceDataStorageCommand",                  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{3, "TimeOfLastDataStorageOperation",           4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{4, "CraftEnableDisableIndicator",              1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{5, "EthernetPortToPortTrafficEnableIndicator", 1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{6, "StaticMulticastVLANTranslationIndicator",  1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{7, "ALUProprietaryMECapabilitiesBitmap",       4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{8, "FlexiblePQAssignmentCapability",           1,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{9, "SLIDCapability",                           1,  ATTR_ACCESS_R_W,    ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetSetFunc},
{10, "YPSerialNumber",                          12, ATTR_ACCESS_R,      ATTR_FORMAT_STRING,         0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{11, "ALUSpecialBehaviorsField",                4,  ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{12, "ALUProprietaryMECapabilitiesBitmapPart2", 25, ATTR_ACCESS_R,      ATTR_FORMAT_UNSIGNED_INT,   0,  0,  0,  NULL, NO_AVC, &generalGetFunc},
{255, "", 0, 0,  0, 0, 0, 0, NULL, 0, NULL}
};

